const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
  entry: path.join(__dirname, "./src/main.js"),
  output: {
    filename: "bundle.js",
    path: path.join(__dirname, "dist"),
    // publicPath: "dist/",
  },
  module: {
    rules: [
      {
        test: /.css$/,
        use: ["style-loader", "css-loader"],
      },
      {
        test: /.png$/,
        use: {
          loader: "url-loader",
          options: {
            limit: 10 * 1024, // 10kb
          },
        },
      },
    ],
  },
  plugins: [
    new CleanWebpackPlugin(),
    // 用于生成index.html
    new HtmlWebpackPlugin({
      title: "webpack-plugin",
      meta: {
        viewport: "width=device-width",
      },
      template: "./src/index.html",
    }),
    // 用于生成about.html
    new HtmlWebpackPlugin({
      filename: "about.html",
    }),
  ],
  mode: "none",
};
